package com.qiyuan.boot.web.controller;


import com.qiyuan.boot.web.bean.SysOss;
import com.qiyuan.boot.web.service.SysOssService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.HashMap;

@RestController
@RequestMapping("/oss")
public class SysOssController {

    @Resource
    private SysOssService sysOssService;


    @ResponseBody
    @PostMapping("/upload")
    public HashMap<String, Object> upload(MultipartFile file){
        HashMap<String,Object> result = new HashMap<>();
        try {
            SysOss sysOss = sysOssService.upload(file);
            result.put("msg",sysOss);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
}
